import request from '@/utils/request'

// 商品列表
export function getshopList(data) {
  var requesturl
  if (data.itemSource === undefined) {
    requesturl = '/v1/item?current=' + data.current + '&size=' + data.size
  } else {
    requesturl = '/v1/item?current=' + data.current + '&size=' + data.size + '&itemSource=' + data.itemSource
  }
  return request({
    url: requesturl,
    method: 'GET'
  })
}
export function getshopListnew(data) {
  var requesturl
  if (data.itemSource === undefined) {
    requesturl = '/v1/item?current=' + data.current + '&size=' + data.size + '&itemType=' + data.itemType
  } else {
    requesturl = '/v1/item?current=' + data.current + '&size=' + data.size + '&itemSource=' + data.itemSource + '&itemType=' + data.itemType
  }
  return request({
    url: requesturl,
    method: 'GET'
  })
}

/** ****************************抢购管理/抽奖管理*******************************************/

export function getSnapupList(data) {
  var requesturl
  if (data.sellerId === undefined) {
    requesturl = '/v1/activityCenter?current=' + data.current + '&size=' + data.size + '&activityType=' + data.activityType
  } else {
    requesturl = '/v1/activityCenter?current=' + data.current + '&size=' + data.size + '&activityType=' + data.activityType + '&sellerId=' + data.sellerId
  }
  return request({
    url: requesturl,
    method: 'GET'
  })
}
export function addSnapupList(data) {
  return request({
    url: '/v1/activityItem',
    method: 'POST',
    data: data
  })
}
export function editorSnapupList(data) {
  return request({
    url: '/v1/activityItem',
    method: 'PUT',
    data: data
  })
}
export function delSnapupList(data) {
  return request({
    url: '/v1/activityCenter',
    method: 'DELETE',
    data: data
  })
}
export function searchSnapupList(data) {
  return request({
    url: '/v1/activityCenter?current=' + data.current + '&size=' + data.size + '&advertName=' + data.advertName + '&type=' + data.type,
    method: 'GET'
  })
}
// 抢购订单
export function activityOrder(data) {
  return request({
    url: '/v1/activityItem/ActivityOrder',
    method: 'POST',
    data: data
  })
}
// 发布活动
export function goActivui(data) {
  return request({
    url: '/v1/activityCenter',
    method: 'PUT',
    data: data
  })
}
// 图库集合
export function getIconList() {
  return request({
    url: '/v1/homePageIcon/getPicList',
    method: 'GET'
  })
}
// 中奖记录
export function getprizeRecordist(data) {
  return request({
    url: '/v1/prizeRecord?current=' + data.current + '&size=' + data.size + '&activityId=' + data.activityId,
    method: 'GET'
  })
}

// 批量活动同步信息
export function getBatchList(data) {
  return request({
    url: '/v1/syncActivity/syncSeller/' + data + '?type=true',
    method: 'POST',
    data: {}
  })
}
export function saveBatchList(data) {
  return request({
    url: '/v1/syncActivity',
    method: 'POST',
    data: data
  })
}
// 获取商品已同步信息
export function delBatchList(data) {
  return request({
    url: '/v1/syncActivity/deleteByActivityId',
    method: 'POST',
    data: data
  })
}
// 核销
export function after(data) {
  return request({
    url: '/v1/prizeRecord/writeOff',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}
